home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / e / amigae21b.lha / Amiga_E_v2.1b / Sources / Utilities / Watch.e < prev    next >
Text File  |  1992-09-02  |  1KB  |  36 lines

  1. /* Watch a file by notification
  2.    pops up a requester when a file gets modified.
  3.    USAGE: watch <file>
  4.    EXAMPLE: run >NIL: watch >NIL: s:startup-sequence       */
  5.  
  6. OPT OSVERSION=37
  7.  
  8. MODULE 'dos/notify'
  9.  
  10. DEF nreq:PTR TO notifyrequest,sig,task,exists
  11.  
  12. PROC main()                       /* make sure file is there: else we'll */
  13.   IF (FileLength(arg)=-1) OR (arg[0]=0)     /* never be notified */
  14.     WriteF('file "\s" does not exist\n',arg)
  15.     CleanUp(10)
  16.   ENDIF
  17.   nreq:=New(SIZEOF notifyrequest)     /* memory is cleared */
  18.   IF nreq=NIL THEN RETURN 20
  19.   sig:=AllocSignal(-1)                /* we want to be signalled */
  20.   IF sig=-1 THEN RETURN 10
  21.   task:=FindTask(0)
  22.   nreq.name:=arg                      /* fill in structure */
  23.   nreq.flags:=NRF_SEND_SIGNAL
  24.   nreq.port:=task                     /* union port/task */
  25.   nreq.signalnum:=sig
  26.   IF StartNotify(nreq)
  27.     WriteF('Now watching: "\s"\n',arg)
  28.     Wait(Shl(1,sig))
  29.     EasyRequestArgs(0,[20,0,0,'File "\s" modified!','Damn!'],0,[arg])
  30.     EndNotify(nreq)
  31.   ELSE
  32.     WriteF('Could not watch "\s".\n',arg)
  33.   ENDIF
  34.   FreeSignal(sig)
  35. ENDPROC
  36.